package com.shiroha.chat.handler;

import com.shiroha.chat.enums.MessageType;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * 策略工厂
 */
@Component
@RequiredArgsConstructor
public class MessageHandlerFactory {

    public static MessageHandler getMessageHandler(MessageType messageType) {
        return switch (messageType) {
            case EMOJI -> EmojiMessageHandler.getInstance();
            case VOICE -> VoiceMessageHandler.getInstance();
            case IMAGE -> ImageMessageHandler.getInstance();
            case FILE -> FileMessageHandler.getInstance();
            case SHARE -> ShareMessageHandler.getInstance();
            default -> throw new IllegalArgumentException("Invalid message type: " + messageType);
        };
    }
}
